import { Injectable } from '@angular/core';
import { HttpClient } from '../../../providers/httpClient';
import { Config } from '../../../providers/config';

@Injectable()
export class EmailSendService {
	constructor(
		public httpClient: HttpClient,
		public config: Config,
	) { }

	editEmail(data, type) {
		if (!data.mailbosid) {
			delete data.mailbosid
		}
		let postBody = {
			"module": "Email",
			"method": type + "Email",
			"params": {
				"mailInfoDto": data
			}
		};
		if (type === "draft") {
		  postBody.method = "draftEmailNoFile";
    }
		console.log("editEmail.postBody", postBody);
		return this.httpClient.post(postBody);
	}

	// 删除邮件
	deleteEmail(id) {
		let postBody = {
			"module": "Email",
			"method": "mailInfoDelete",
			"params": {
				"ids": id
			}
		};
		return this.httpClient.post(postBody, {
			isShowLoading: false
		});
	}
}
